package com.zxk.api.dao;

import com.zxk.core.common.model.Fund;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface FundDao extends JpaRepository<Fund,Long> {

//    https://blog.csdn.net/qq_38408785/article/details/102863190?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522159871008019724811860470%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=159871008019724811860470&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v3~rank_business_v1-1-102863190.ecpm_v3_rank_business_v1&utm_term=JpaRepository查找区间&spm=1018.2118.3001.4187

    @Query(value = "select * from fund order by create_time desc",nativeQuery = true)
    public List<Fund> findByCreateTime();

    //JPA写sql语句
//    https://blog.csdn.net/yanxilou/article/details/83110805


//    @Query("select toUserId from Relationship where fromUserId =:fromUserId")
//    List<Long> findByFromUserId(@Param("fromUserId") Long fromUserId);

//    @Query(value = "SELECT DISTINCT t1.to_user_id FROM (SELECT * FROM relationship WHERE from_user_id = ?1)  AS t1 INNER JOIN relationship t2 ON t1.to_user_id = t2.from_user_id ", nativeQuery = true)
//    List<Long> findFriendsByUserId(Long userId);
}
